import { VAR } from "../introduce.js";
window.onload = function () {
  // 顶栏点击事件
  const a = document.querySelector(".topPreset a");
  a.addEventListener("touchstart", function () {
    console.log(111);
    location.href = "./taskingDetails.html";
  });
  // 获取数据
  let arr = [];
  arr = JSON.parse(localStorage.getItem("dataAbnormal"));
  const abnorTimes = document.querySelector(".content1 .abnortiames");
  abnorTimes.innerText = arr[0].times || "2022.05.04 13:00";
  // 地址
  const abnorAddress = document.querySelector(".address .abnoraddress");
  abnorAddress.innerText = arr[0].address || "浙江省 杭州市 钱塘区";
  // 类型
  const abnorcompo = document.querySelector(".kind .compo");
  abnorcompo.innerText = arr[0].type || "发动机启动困难";
  // 描述
  const abnortext = document.querySelector(".text");
  abnortext.innerText = arr[0].datail || "车子启动困难";
  // 图片
  // 点击加载图片上传图片
  const ul1 = document.querySelector(".voucher ul");
  const ul2 = document.querySelector(".goodsImag ul");
  const btnfirn = document.querySelector(".voucher .firm");
  const btnimgs = document.querySelector(".goodsImag .imgs");
  renderImg(ul1);
  renderImg(ul1);
  renderImg(ul2);
  renderImg(ul2);

  function renderImg(ul) {
    //取到n~m的随机整数
    function getRandom(n, m) {
      return Math.floor(Math.random() * (m - n + 1)) + n;
    }
    //调用
    let random = getRandom(1, 3);

    const li = document.createElement("li");
    li.innerHTML = `
      <li><img src="./image/收据${random}.png" alt>
      </li>`;
    ul.append(li);
  }
};
